<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>v-once指令</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <div id="root">
        <div v-once>初始的n值是{{n}}</div>
        <div>当前的n值是{{n}}</div>
        <button @click="n++">点我n加1</button>
    </div>
    <script>
        /*
        v-once指令
        1.v-once所在节点在初次动态渲染后就视为静态内容了
        2.以后数据的改变不会引起v-once所在结构的更新 ,可以用于优化性能

        */
        Vue.config.productionTip = false
        var vm = new Vue({
            el: '#root',
            data: {
                n: 1
            },
            methods: {}
        });
    </script>
</body>

</html>